﻿using System;
using NLog;

namespace CurrencySpider.BackGroundJob
{
    public class JobManage
    {
        private readonly static ILogger logger = LogManager.GetCurrentClassLogger();
        /// <summary>
        /// 开启作业
        /// </summary>
        public static void Start()
        {
            try
            {
                //执行任务
                QuartzManager.AddJob("CurrencySpiderJob", "CurrencySpiderJobGroup", "CurrencySpiderJobJobTrigger", "CurrencySpiderJobJobTriggerGroup",
                    System.Configuration.ConfigurationManager.AppSettings["CnySpiderTime"], typeof(CnySpider));
            }
            catch (Exception exception)
            {

                logger.Debug(exception, $"爬虫作业管理：管理异常.异常信息：{exception.Message}");
            }
        }
        /// <summary>
        /// 关闭所有作业
        /// </summary>
        public static void ShoutDown()
        {
            QuartzManager.ShutdownJobs();
        }
    }
}